define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        task_list: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'caring_task_order/task_list/ids/'+Config.ids + location.search,
                    // add_url: 'caring_task_order/add',
                    // edit_url: 'caring_task_order/edit',
                    // del_url: 'caring_task_order/del',
                    multi_url: 'caring_task_order/multi',
                    import_url: 'caring_task_order/import',
                    table: 'caring_task_order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible: false,
                search:false,
                showColumns:false,
                showExport:false,
                commonSearch:false,
                pageSize: 10,
                showToggle: false,
                columns: [
                    [
                        {field: 'id', title: __('Id')},
                        {field: 'nickname', title: __('Nickname'), operate: false},
                        {field: 'region_address', title: __('Region_address'), operate: false},
                        {field: 'caring_task.arrivaltime', title: __('Caring_task.arrivaltime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'caring_task.peoplenum', title: __('Caring_task.peoplenum'), operate: false},
                        {field: 'caring_task.score', title: __('Caring_task.score'), operate: false},
                        {field: 'caring_task.workinghours', title: __('Caring_task.workinghours'), operate: false},
                        {field: 'order_receiving_time', title: __('Order_receiving_time'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'completiontime', title: __('Completiontime'), operate:false, addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});